#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>

using namespace std;

// https://leetcode.cn/problems/longest-consecutive-sequence/?envType=study-plan-v2&envId=top-100-liked

class Solution {
public:
    int longestConsecutive(vector<int>& nums) {
        unordered_set<int> numSet(nums.begin(), nums.end());
        int ans = 0;
        for(int curNum : numSet){
            if(numSet.find(curNum - 1) != numSet.end()){
                continue;
            }
            // 往后
            int curCnt = 1;
            int temp = curNum + 1;
            while (numSet.find(temp) != numSet.end()){
                temp++;
                curCnt++;
            }
            ans = ans > curCnt ? ans : curCnt;
        }
        return ans;
    }
};

int main()
{
    return 0;
}